
using Backoffice.Domain.Repositories;
using Backoffice.Infrastructure.Data;
using Backoffice.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace BackOffice.Infrastructure;

public static class ServiceCollectionExtensions
{
    public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddDbContext<BackOfficeDbContext>(options =>
            options.UseNpgsql(configuration.GetConnectionString("pgsql")));
        // 可在此注册更多基础设施相关服务

        services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));
        
        return services;
    }
}